Skip to content

Collapse single-implementation Airflow trait layer - #697

Open
jvanbuel wants to merge 1 commit into
claude/remove-dead-api-operationsfrom
claude/collapse-airflow-trait-layer
Open

Collapse single-implementation Airflow trait layer#697
jvanbuel wants to merge 1 commit into
claude/remove-dead-api-operationsfrom
claude/collapse-airflow-trait-layer

Conversation

@jvanbuel

Copy link
Copy Markdown
Owner

Stacked on #696. Both touch src/airflow/traits/, so this targets that branch rather than main. GitHub will retarget it to main automatically once #696 merges. Review #696 first.

What

Deletes src/airflow/traits/ — six operation traits (DagOperations, DagRunOperations, TaskInstanceOperations, LogOperations, DagStatsOperations, TaskOperations) plus the AirflowClient super-trait. Every one had exactly one implementer: FlowrsClient.

Net: −187 lines, −1 direct dependency.

Why the abstraction never paid off

The module doc stated the intent:

This trait can be implemented by different API versions (v1 for Airflow v2, v2 for Airflow v3) to provide a consistent interface for interacting with Airflow.

That is not how the version split was built. FlowrsClient is an enum, and every method dispatches internally:

match self {
    Self::V1(client) => ...,
    Self::V2(client) => ...,
}

So the versioning the traits were designed for lives one layer down, and the trait layer sat on top adding a second dispatch mechanism over a single type.

Changes

  • Six impl XOperations for FlowrsClient blocks become inherent impl FlowrsClient blocks. Method bodies are untouched.
  • Arc<dyn AirflowClient>Arc<FlowrsClient> across the worker, environment_state, and tests/common/mod.rs.
  • #[async_trait] removed from those impls — inherent async fn needs no macro.
  • async-trait dropped from flowrs-tui's dependencies. It remains in flowrs-airflow for AuthProvider, which has seven implementations and is genuine polymorphism.

On the dyn removal

tests/common/mod.rs returned Arc<dyn AirflowClient> from its helpers, but only ever constructed a FlowrsClient. The dyn was type erasure over one concrete type, not polymorphism, so nothing is lost. If a mock client is wanted later, reintroducing a trait at that point is cheap and can be shaped around the actual test need rather than guessed at in advance.

Verification

cargo test --workspace --lib --bins (94 passing), cargo clippy --workspace --all-targets --all-features -- -D warnings, and cargo fmt --all --check all clean. Clippy covers --all-targets, so the integration test crates compile too.

🤖 Generated with Claude Code

https://claude.ai/code/session_0127jzUgqqy8JVX5RydfQxh8


Generated by Claude Code

src/airflow/traits/ defined six operation traits plus an AirflowClient
super-trait, all implemented solely by FlowrsClient. The module doc said
the traits existed so "different API versions (v1 for Airflow v2, v2 for
Airflow v3)" could each implement them, but that split was instead built
inside FlowrsClient as an enum, so the abstraction never gained a second
implementer.

Convert the six impl blocks into inherent impls on FlowrsClient, replace
Arc<dyn AirflowClient> with Arc<FlowrsClient> at every call site, and
delete the traits module. The dyn indirection was type erasure over one
concrete type, including in tests/common/mod.rs, so no polymorphism is
lost.

Drops the now-unused async-trait dependency from flowrs-tui; the client
crate still uses it for AuthProvider, which has seven implementations.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0127jzUgqqy8JVX5RydfQxh8
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 008f6a3b-32a2-42c5-b654-3d8c89dfaa41

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/collapse-airflow-trait-layer

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants